Skip to content

fix(executor): restore tty foreground pgrp for interactive sessions#42

Merged
Pierozi merged 1 commit intomainfrom
fix/interactive
Apr 27, 2026
Merged

fix(executor): restore tty foreground pgrp for interactive sessions#42
Pierozi merged 1 commit intomainfrom
fix/interactive

Conversation

@Pierozi
Copy link
Copy Markdown
Contributor

@Pierozi Pierozi commented Apr 27, 2026

Summary

  • PR feat(executor): forward signals to sandboxed process group to prevent orphans #39 placed the sandboxed child in its own process group for signal forwarding, but this detached it from the tty's foreground group — any tty read then raises SIGTTIN and the interactive shell hangs indefinitely.
  • Adds TtyForegroundGuard: after spawning, hands the tty foreground to the child's pgrp via tcsetpgrp (with SIGTTOU suppressed during the handoff), and restores the original foreground on drop.
  • RAII pattern mirrors the existing PgidKillGuard, ensuring the parent reclaims the tty on all exit paths including panics.

Test plan

  • Run sx online in an interactive terminal — shell should accept input without hanging
  • Run sx offline and type a command — verify normal interactive behavior
  • Ctrl-C inside the sandbox exits cleanly (signal forwarding from feat(executor): forward signals to sandboxed process group to prevent orphans #39 still works)
  • Run sx -- echo hi (non-interactive) — guard is a no-op, output is correct
  • Run cargo test — all existing tests pass

When the sandboxed child was placed in its own process group (#39),
it was no longer the tty foreground group, causing SIGTTIN on any
tty read and hanging interactive shells.

Add TtyForegroundGuard: hands the tty foreground to the child pgrp
via tcsetpgrp after spawn (SIGTTOU suppressed during handoff) and
restores the original foreground on drop.
@Pierozi Pierozi merged commit 8f986e0 into main Apr 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant